package bancosys.tec.services.test.services;

import jmine.tec.di.annotation.Injected;
import jmine.tec.services.ServicesController;
import jmine.tec.services.annotations.Execution;
import jmine.tec.services.annotations.Input;
import jmine.tec.services.annotations.Output;
import jmine.tec.services.annotations.ServiceImplementor;
import jmine.tec.services.annotations.Validation;
import jmine.tec.services.api.ActionsEnum;
import junit.framework.Assert;

@ServiceImplementor(action = ActionsEnum.INCLUIR)
public class Mock2Service extends Assert {

    private String outro;

    private ServicesController controller;

    private boolean validationRan;

    public Mock2Service(@Input(fieldName = MockService.CAMPO_OBRIGATORIO_1) String a) {
        assertNotNull(a);
    }

    @Input
    public void setCampoObrigatorio2(String outro) {
        this.outro = outro;
        assertNotNull(this.controller);
    }

    @Injected
    public void setServiceController(ServicesController controller) {
        this.controller = controller;
        assertNull(this.outro);
    }

    @Validation(validateRuntimeException = true)
    public void validate() {
        this.validationRan = true;
        this.controller.toString();
    }

    @Execution
    @Output(propertyName = "saida")
    public boolean execute(@Input(fieldName = MockService.CAMPO_OBRIGATORIO_1) String a,
            @Input(fieldName = MockService.CAMPO_OBRIGATORIO_2) boolean campo) {
        assertNotNull(this.outro);
        assertTrue(this.validationRan);
        assertTrue(campo);
        return this.validationRan;
    }

}
